﻿namespace EyeOpen.BomberMan
{
	using System.Collections.Generic;
	using System.Drawing;
	using System.Reflection;

	public class ImageInitializer
	{
		private readonly Assembly assembly;
		private readonly string resourcePath;
		private Size size;

		public ImageInitializer(Assembly assembly, string resourcePath)
		{
			this.assembly = assembly;
			this.resourcePath = resourcePath;
		}

		public IList<Image> Get(Size size)
		{
			this.size = size;

			var imageList = new List<Image>();

			var man = GetBitmap("Man.png", true);
			var wall = GetBitmap("Wall.jpg");
			var rock = GetBitmap("Rock.jpg");
			var bomb = GetBitmap("Bomb.png");

			imageList.Insert((int)ItemType.Wall, wall);
			imageList.Insert((int)ItemType.Rock, rock);
			imageList.Insert((int)ItemType.Player, man);
			imageList.Insert((int)ItemType.Bomb, bomb);

			return imageList;
		}

		private Bitmap GetBitmap(string resourceName, bool makeTransparent = false)
		{
			return assembly.GetBitmap(resourcePath + "." + resourceName, size, makeTransparent);
		}
	}
}